package com.miaowang.salad.activity;

import android.content.Intent;
import android.os.Bundle;
import android.os.SystemClock;
import android.view.KeyEvent;

import com.miaowang.salad.jobqueue.JobEvents;
import com.miaowang.salad.util.ActivityUtils;

import de.greenrobot.event.Subscribe;
import de.greenrobot.event.ThreadMode;

/**
 * 闪屏
 * 
 * @author weihe
 * 
 */
public class SplashActivity extends BaseActivity {

	private static final String TAG = SplashActivity.class.getSimpleName();

	private static final int mSleepTime = 1000; // 闪屏停留的时间

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		new Thread(new Runnable() {
			@Override
			public void run() {
				SystemClock.sleep(1000);
				Intent intent = new Intent();
				intent.setClass(SplashActivity.this, UserLoginActivity.class);
				startActivity(intent);
				finish();
			}
		}).start();
	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_BACK) {
			ActivityUtils.exitApp(this);
			return true;
		}
		return super.onKeyDown(keyCode, event);
	}
	

	// EventsBus
	@Subscribe(threadMode = ThreadMode.MainThread)
	public void onEventMainThread(JobEvents.JobSuccess e) {
	}
	@Subscribe(threadMode = ThreadMode.MainThread)
	public void onEventMainThread(JobEvents.JobFailure e) {
	}

	@Override
	protected void onDestroy() {
		super.onDestroy();
	}
}
